from django.conf.urls import url
from rest_framework.routers import DefaultRouter
from rest_framework_jwt.views import obtain_jwt_token

from apps.users import views

urlpatterns = [
    url(r'^usernames/(?P<username>\w{5,20})/count/$', views.CheckUsernameView.as_view()),  #校验用户名是否存在
    url(r'^phones/(?P<mobile>1[345789]\d{9})/count/$', views.CheckMobileView.as_view()),  #校验手机号是否存在
    url(r'^$',views.RegisterUserView.as_view()) , #注册视图
    # url(r'^auths/$',obtain_jwt_token) , #登陆视图
    url(r'^auths/$',views.UserObtainJSONWebToken.as_view()) , #登陆视图
    url(r'^infos/$',views.UserInfoView.as_view()),  #用户中心首页展示的数据
    url(r'^emails/$',views.EmailSendView.as_view()),  #保存邮箱
    url(r'^emails/verification/$',views.EmailActiveView.as_view()),  #验证邮箱视图
    # url(r'^addresses/$',views.AddressView.as_view({"get":"list","post":"create"})),  #验证邮箱视图
    url(r'^browerhistories/$', views.UserBrowerHistoryView.as_view()),  # 用户浏览记录yuuu

]

#1,创建DefaultRouter对象
router = DefaultRouter()
#2,注册视图集
router.register(r'addresses',views.AddressView,base_name="address")
#3,添加到urlpatterns
urlpatterns += router.urls